using System.Linq;
using NUnit.Framework;

namespace Flit.Tests
{
    [TestFixture]
    public class GraphTest : ParserTestBase
    {
        [Test]
        public void HasStates()
        {
            Graph node = Parse("digraph g{x y; z}");
            Assert.AreEqual(3, node.States.Count());
        }

        [Test]
        public void HasTransitions()
        {
            Graph node = Parse("digraph g{x y; z z->x z-> y}");
            Assert.AreEqual(2, node.Transitions.Count());
        }

        [Test]
        public void ImplicitStatesAreCreated()
        {
            Graph node = Parse("digraph g{z z->x z->y y->z}");
            Assert.AreEqual(2, node.States.Where(x => x.IsImplicit).Count());
            Assert.AreEqual(3, node.States.Count());
            Assert.IsTrue(node.States.All(x => x.Graph == node));
        }

    }
}